package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class test3 {
    public static void main(String[] args) throws IOException {
                Scanner scanner = new Scanner(System.in);
                FileOutputStream fis = new FileOutputStream("test2.txt",true);
                while (true){
                    System.out.println("请输入内容");
                    String  sca = scanner.nextLine();
                    if ("exit".equalsIgnoreCase(sca)) {
                        break;
                    }else {
                        byte[] by = sca.getBytes(StandardCharsets.UTF_8);
                        fis.write(by);
                    }
                }
                fis.close();
                System.out.println("写入完成");
            }
        }

